package com.jumi.microservice.constant.taobao;

import com.jumi.microservice.common.base.dto.AbstractEnum;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Dirk
 * @Date 2021-01-16 08:46
 */
public enum TaoBaoOrderStatusEnum implements AbstractEnum<Byte> {

    /**
     * 淘宝原始订单状态对应聚米订单状态编码枚举
     */
    PAID(1, "已付款"),
    RECEIVED(1, "已收货"),
    SETTLED(2, "已结算"),
    INVALID(3, "已失效");


    private Byte code;

    private String desc;

    TaoBaoOrderStatusEnum(Integer code, String desc) {
        this.code = code.byteValue();
        this.desc = desc;
    }

    @Override
    public Byte getCode() {
        return code;
    }

    public void setCode(Byte code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    private static final Map<String, TaoBaoOrderStatusEnum> TAO_BAO_ORDER_STATUS_ENUM_MAP = new HashMap<>();

    static {
        for (TaoBaoOrderStatusEnum taoBaoOrderStatusEnum : TaoBaoOrderStatusEnum.values()) {
            TAO_BAO_ORDER_STATUS_ENUM_MAP.put(taoBaoOrderStatusEnum.getDesc(), taoBaoOrderStatusEnum);
        }
    }

    public static TaoBaoOrderStatusEnum getByDesc(String desc) {
       return TAO_BAO_ORDER_STATUS_ENUM_MAP.get(desc);
    }
}
